from fastapi import FastAPI, BackgroundTasks, UploadFile, File, Form, Depends, HTTPException, status, Request
from fastapi.middleware.cors import CORSMiddleware

# from fastapi_mail import FastMail, MessageSchema, ConnectionConfig
from dotenv import dotenv_values
from pydantic import BaseModel
from typing import List
from fastapi.responses import HTMLResponse
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates

from tortoise.contrib.fastapi import register_tortoise

from project.routers import dish

app = FastAPI()
app.mount("/static", StaticFiles(directory="static"), name="static")
templates = Jinja2Templates(directory="templates")
core_origins = [
    "http://*",
    "*",
]
app.add_middleware(
    CORSMiddleware,
    allow_origins=core_origins,
    allow_credentials=True,
    allow_headers=["*"],
    allow_methods=["*"],
)

app.include_router(dish.router)

# config_credentials = dotenv_values("project/utils/.env")


# @app.get("/", response_class=HTMLResponse)
# async def read_item(request: Request):
#     return templates.TemplateResponse("note.html", {"request": request})


# @app.get("/viminfo", response_class=HTMLResponse)
# async def read_item(request: Request):
#     return templates.TemplateResponse("viminfo.html", {"request": request})


register_tortoise(
    app,
    db_url="sqlite://db.sqlite3",
    modules={"models": ["project.models"]},
    generate_schemas=True,
    add_exception_handlers=True,
)
